package HIR.Dialog;

import javax.swing.*;

import java.awt.*;


import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.io.*;
import javax.swing.event.*;

import HIR.graph.Gantt;
import HIR.graph.cpuGantt;

import java.awt.*;
import java.awt.event.*;
import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.util.*;

public class shadowDialog extends JDialog { 
   
 
	
	private int i=1;
	private boolean couleur=true;

	public void paint(Graphics g) {
	//	super.paint(G);
		Image image = createImage(500,500);
		Graphics2D G = (Graphics2D) image.getGraphics();
		if (i == 1 )	couleur = ! couleur ;
		
		//G.clearRect(0,0,this.HEIGHT,this.WIDTH);
		G.setColor(Color.white);
		
		G.fillRect(0,0,this.HEIGHT,this.WIDTH);
		Color C = couleur ? Color.red : Color.green;
		
		G.setColor(C);
	//this.getRootPane().putClientProperty("Window.alpha", new Float(1f));
		//G.drawString("TEST " , 10, 10);
		//JLabel statusLabel = new JLabel("TEST");
		//this.getRootPane().putClientProperty("Window.alpha", new Float(0.5f));
	//	G.fillRect(this.getHeight()/i ,this.getWidth()/2, 10, 10);
	
		for (int j=0; j < i ; j++){
			G.fillRect( 10+ (20*j),10, 10, 10);
			//System.out.print("+");
		}
	//	System.out.println("");
		g.drawImage(image, 0, 0, this);
	}

    public shadowDialog(Gantt gantt) throws HeadlessException{ 
        super(); 
        
        init();
        
   
        
        this.getRootPane().putClientProperty("Window.alpha", new Float(0.5f));
    } 
	
    private void init(){ 
		this.setUndecorated (true);
		//this.setModal(true);
		this.getRootPane().putClientProperty("Window.alpha", new Float(1f));
		
		//JLabel statusLabel = new JLabel("TEST");
		this.getRootPane().putClientProperty("Window.alpha", new Float(0.5f));
		this.setSize(130,30);
	
     
		 JPanel contents = (JPanel)getContentPane(); 
	        contents.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); 
	    //    contents.add(statusLabel, BorderLayout.NORTH); 
        
        setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); 
        Dimension ecran = Toolkit.getDefaultToolkit().getScreenSize();
       setLocation((ecran.width-getWidth())/2, (ecran.height-getHeight())/2);
        //setLocation(0, 0);
        //this.setSize(ecran.width, ecran.height);
        
    }

    
	public void activate(JPanel panel) {
		this.setVisible(true);
		setLocationRelativeTo(null); 
		/*System.out.println(panel.getBounds());
		System.out.println(panel.getParent().getParent().getParent().getParent().getBounds());
		*/
		Graphics2D screenGraphics =(Graphics2D) this.getGraphics(); 
		this.paint(screenGraphics);
	
		// TODO Auto-generated method stub
		
	}

	public void resume() {
		this.dispose();
		// TODO Auto-generated method stub
		
	}

	public void setValue(int i) {
		
		
		if (i %7 != this.i ) {
			this.i =  i %7 ;
			Graphics2D screenGraphics =(Graphics2D) this.getGraphics(); 
			//this.paint(screenGraphics);
			this.update(screenGraphics);
		}
		// TODO Auto-generated method stub
		
	} 
	
	

} 
